import type { BaseTableConfig } from '@/components/base-ui/base-table/type';
import { generateRandomId } from '@/utils';

export const tableConfig: BaseTableConfig = {
    items: [
        {
            tableSlot: 'index'
        },
        {
            modelKey: 'level',
            slotName: 'level',
            noEdit: true,
            columnProps: {
                label: 'BOM层级',
                width: 180
            },
            validProps: {
                id: generateRandomId()
            }
        },
        {
            modelKey: 'materialCode',
            slotName: 'materialCode',
            columnProps: {
                label: '子项物料编码',
                width: 180,
                customRequired: true
            },
            validProps: {
                id: generateRandomId(),
                required: true
            },
            validRules: {
                errMsgFn: (rowNum: number, columnNum: number) => {
                    return `请完善表格第 ${rowNum + 1} 行，第 ${columnNum} 列的子项物料编码信息`;
                }
            }
        },
        {
            modelKey: 'materialName',
            slotName: 'materialName',
            columnProps: {
                label: '子项物料名称',
                width: 180
            },
            validProps: {
                id: generateRandomId()
            }
        },
        {
            modelKey: 'productionType',
            slotName: 'productionType',
            columnProps: {
                label: '生产类型',
                width: 180
            },
            validProps: {
                id: generateRandomId()
            }
        },
        {
            modelKey: 'materialSpecification',
            slotName: 'materialSpecification',
            columnProps: {
                label: '规格型号',
                width: 180
            },
            validProps: {
                id: generateRandomId()
            }
        },
        {
            modelKey: 'unit',
            slotName: 'unit',
            columnProps: {
                label: '生产单位',
                width: 180
            },
            validProps: {
                id: generateRandomId()
            }
        },
        {
            itemType: 'number',
            modelKey: 'unitUsage',
            columnProps: {
                label: '单件用量',
                width: 180,
                customRequired: true
            },
            elInputNumberProps: {
                min: 1,
                max: 9999999999.99,
                precision: 2
            },
            validProps: {
                id: generateRandomId(),
                required: true
            },
            validRules: {
                errMsgFn: (rowNum: number, columnNum: number) => {
                    return `请完善表格第 ${rowNum + 1} 行，第 ${columnNum} 列的单件用量信息`;
                }
            }
        },
        {
            modelKey: 'remarks',
            columnProps: {
                label: '备注',
                width: 240
            },
            elInputProps: {
                type: 'textarea',
                maxlength: '50',
                showWordLimit: true
            },
            validProps: {
                id: generateRandomId()
            }
        }
    ],
    unIndex: true,
    unSelection: true,
    modalActionShow: true
};
